package xj.meta;

/**********************************************************************************
 *
 * @author Xiaoping Jia
 * @version 0.2
 *
 * Created on: 2005/05/01
 * Requires: J2SE 5.0
 *
 **********************************************************************************/

import java.util.UUID;

public abstract class AbstractElement {

  @Override
  public Object clone() throws CloneNotSupportedException {
    AbstractElement e = (AbstractElement) super.clone();
    // e.uuid = UUID.randomUUID();
    e.id = (idPrefix + nextId());
    return e;
  }

  public UUID getUUID() {
    return uuid;
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  protected AbstractElement() {
    id = (idPrefix + nextId());
  }

  public static void setPrefix(String prefix) {
    if (prefix != null) {
      idPrefix = prefix;
    }
  }

  public String getNextId() {
    return (idPrefix + nextId());
  }

  protected final UUID uuid = UUID.randomUUID();

  protected static String idPrefix = "e";

  private static int id_ = 1;

  protected int nextId() {
    return id_++;
  }

  protected String id;

}
